<template>
	<view class="content">
		<view class="Realname">
			<image src="/static/img/Realname.png" mode="widthFix"/>
		</view>
		<view class="form-wrap">
			<view class="form-item">
				<image class="icon" src="/static/img/yanzhengma_icon.png" mode=""></image>
				<input v-model="name" type="text" placeholder="请输入真实姓名">
			</view>
			<view class="form-item">
				<image class="icon" src="/static/img/yanzhengma_icon.png" mode=""></image>
				<input v-model="card" type="text" placeholder="请输入身份证号码">
			</view>
		</view>
		<view class="btn-wrap">
			<button type="primary" @click="submit">提交</button>
			<view>身份信息仅有于实名认证，请放心填写</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				userInfo: {},
				name: '',
				card: '',
			}
		},
		onLoad(options) {
			this.userInfo = JSON.parse(options.userinfo)
		},
		onReady() {
			
		},
		methods: {
			submit: function () {
				if (this.name == '') {
					uni.showToast({
						title: '请输入真实姓名',
						position: 'bottom',
						icon: 'none'
					});
					return false;
				}
				if (this.card == '') {
					uni.showToast({
						title: '请输入身份证号码',
						position: 'bottom',
						icon: 'none'
					});
					return false;
				}
				uni.showLoading({
					title: '',
				});
				this.$api.api.ajaxData({
					method: 'V1.UserAuth',
					uid: this.userInfo.id,
					token: this.userInfo.token,
					type: '3',
					name: this.name,
					card: this.card,
				}, res => {
					uni.hideLoading();
					uni.showToast({
						title: res.msg,
						position: 'bottom',
						icon: 'none'
					});
					if (res.status) {
						uni.$emit('my-page', {
							type: 'update',
						})
						uni.navigateBack({
							delta: 1
						})
					}
				}, err => {
					uni.hideLoading();
					uni.showToast({
						title: '网络错误，请稍后再试',
						position: 'bottom',
						icon: 'none'
					});
				})
			},

		}
	}
</script>

<style lang="scss">
	@import '../../common/common.scss';
	.form-wrap {
		.form-item {
			display: flex;
			justify-content: flex-start;
			align-items: center;
			background: #FFFFFF;
			padding: 0 50rpx;
			margin-top: -15rpx;
			& + .form-item {
				border-top: 1rpx solid $border-light-color;
			}

			.icon {
				width: 40rpx;
				height: 40rpx;
			}

			input {
				flex: 1;
				height: 100rpx;
				line-height: 100rpx;
				text-indent: 20rpx;
				font-size: 24rpx;
			}
		}
	}

	.btn-wrap {
		margin-top: 100rpx;
		padding: 0 100rpx;

		button {
			border-radius: 100rpx;
		}
		>view{
			color: #999;
			margin-top: 10rpx;
			text-align: center;
		}
	}
	.Realname{
		>image{
			width: 750rpx;
		}
	}
</style>
